import { request } from 'umi';

import {
  AreaListParamsType,
  DeleteDoorType,
  DoorListParamsType,
  PlanModeParamsType,
  AddDoorType,
  SentDownPlanModeType,
  DoorInfoType,
  ConfigPermissionParamsType,
  IdParamsType,
  ConfigPermissionRecordParamsType,
} from './API';
//
export async function queryAreaListAPI(params?: AreaListParamsType) {
  return request<API.APIReturnType<any>>('/api/area/listArea', { params: params || {} });
}

export async function queryDoorListAPI(params?: DoorListParamsType) {
  return request<API.APIReturnType<any>>('/api/door/list', { params: params || {} });
}
export async function queryUserListAPI(params?: DoorListParamsType) {
  return request<API.APIReturnType<any>>('/api/user/list', { params: params || {} });
}
export async function queryPlanModeAPI(params?: PlanModeParamsType) {
  return request<API.APIReturnType<any>>('/api/planMode/list', { params: params || {} });
}
export async function deletePermissionAPI(params?: ConfigPermissionParamsType) {
  return request<API.APIReturnType<any>>('/api/dp/deletePermission', {
    method: 'post',
    data: params || {},
  });
}
export async function addPermissionAPI(params?: ConfigPermissionParamsType) {
  return request<API.APIReturnType<any>>('/api/dp/addPermission', {
    method: 'post',
    data: params || {},
  });
}
export async function configPermissionAPI(params?: ConfigPermissionParamsType) {
  return request<API.APIReturnType<any>>('/api/dp/configPermission', {
    method: 'post',
    data: params || {},
  });
}
export async function queryUserConfigPermissionRecordAPI(
  params?: ConfigPermissionRecordParamsType,
) {
  return request<API.APIReturnType<any>>('/api/user/configPermissionRecord', {
    params: params || {},
  });
}
export async function queryDoorConfigPermissionRecordAPI(
  params?: ConfigPermissionRecordParamsType,
) {
  return request<API.APIReturnType<any>>('/api/door/configPermissionRecord', {
    params: params || {},
  });
}
export async function queryDoorListByUserAPI(params?: IdParamsType) {
  return request<API.APIReturnType<any>>('/api/dp/doorListByUser', { params: params || {} });
}
export async function queryCardUserListByDoorAPI(params?: IdParamsType) {
  return request<API.APIReturnType<any>>('/api/dp/cardUserListByDoor', { params: params || {} });
}
export async function queryControllerTypeAPI() {
  return request<API.APIReturnType<any>>('/api/door/controllerType');
}
export async function queryDoorOpenTypeAPI() {
  return request<API.APIReturnType<any>>('/api/door/openType');
}
export async function addDoorAPI(params?: AddDoorType) {
  return request<API.APIReturnType<any>>('/api/door/add', { method: 'post', data: params || {} });
}
export async function sentDownPlanModeAPI(params?: SentDownPlanModeType) {
  return request<API.APIReturnType<any>>('/api/door/sentDownPlanMode', {
    method: 'post',
    data: params || {},
  });
}
export async function deleteDoorAPI(params?: DeleteDoorType) {
  return request<API.APIReturnType<any>>('/api/door/delete', {
    method: 'post',
    data: params || {},
  });
}
export async function editDoorAPI(params?: AddDoorType) {
  return request<API.APIReturnType<any>>('/api/door/edit', { method: 'post', data: params || {} });
}
export async function queryDoorInfoAPI(params?: DoorInfoType) {
  return request<API.APIReturnType<any>>('/api/door/info', { params: params || {} });
}
export async function isConfigAPI(params?: { doorIds?: string; userIds?: string }) {
  return request<API.APIReturnType<any>>('/api/dp/isConfig', {
    method: 'post',
    data: params || {},
  });
}
